package org.linlinjava.litemall.db.service;

import com.github.yulichang.base.MPJBaseServiceImpl;
import org.linlinjava.litemall.db.dao.LumierePayMemberMapper;
import org.linlinjava.litemall.db.domain.LumiereLevelMember;
import org.linlinjava.litemall.db.domain.LumierePayMember;
import org.linlinjava.litemall.db.domain.LumierePayMemberExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 卢米埃支付会员服务
 *
 * @author yliyun
 * @date 2022/09/21
 */
@Service
public class LumierePayMemberService extends MPJBaseServiceImpl<LumierePayMemberMapper,LumierePayMember> {

    /**
     * 卢米埃支付成员映射器
     */
    @Resource
    private LumierePayMemberMapper lumierePayMemberMapper;

    /**
     * 列表
     *
     * @param example 例子
     * @return {@link List}<{@link LumierePayMember}>
     */
    public List<LumierePayMember> list(LumierePayMemberExample example){
        return lumierePayMemberMapper.selectByExample(example);
    }

    /**
     * 添加
     *
     * @param lumierePayMember 卢米埃支付会员
     */
    public void add(LumierePayMember lumierePayMember){
        lumierePayMemberMapper.insert(lumierePayMember);
    }

    /**
     * 更新
     *
     * @param lumierePayMember 卢米埃支付会员
     */
    public void update(LumierePayMember lumierePayMember){
        lumierePayMemberMapper.updateByPrimaryKey(lumierePayMember);
    }

    /**
     * 删除
     *
     * @param payMemberId 付费会员id
     */
    public void delete(Integer payMemberId){
        lumierePayMemberMapper.logicalDeleteByPrimaryKey(payMemberId);
    }

//    public Integer countByMemberId(LumierePayMemberExample example){
//       return (int)lumierePayMemberMapper.countByExample(example);
//    }

    /**
     * 发现通过id
     *
     * @param memberId 成员身份
     * @return {@link LumierePayMember}
     */
    public LumierePayMember findById(Integer memberId){
        return lumierePayMemberMapper.selectByPrimaryKey(memberId);
    }

    /**
     * 找到名字
     *
     * @param name 名字
     * @return {@link List}<{@link LumierePayMember}>
     */
    public List<LumierePayMember> findByName(String name){
        LumierePayMemberExample example = new LumierePayMemberExample();
        example.or().andDeletedEqualTo(false).andNameEqualTo(name);

        return lumierePayMemberMapper.selectByExample(example);
    }

}
